<?php
/**
 * Created by PhpStorm.
 * User: yadongw
 * Date: 15-5-26
 * Time: 下午7:46
 */
use UcxApiSdk\Client;
include 'common.php';

$client = new Client();
$client->setAccessToken($_COOKIE['ucx_access_token']);
$libraryResource = $client->getLibrary();
$lid = $_GET['lid'];
$library = $libraryResource->find($lid);
if($_POST){
	try{
		$library = $libraryResource->update($lid, $_POST['Library']);
	}catch (Exception $e){
		echo "Error: " . $e->getMessage();
	}
}
?>
<html>
<head>
	<link href="../static/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
	<script type="text/javascript" src="../static/jquery.min.js"></script>
	<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>

</head>
<body>
<form id="w0" class="form-horizontal webform-box" method="post">
	<h2 class="webform-title">Library Information</h2>
	<div class="form-group field-library-name required">
		<label class="control-label col-md-4" for="library-name">Name</label>
		<div class="col-md-6"><input type="text" id="library-name" class="form-control" name="Library[name]" value="<?= $library['name'] ?>">

			<div class="help-block"></div></div>
	</div>
	<div class="form-group field-library-ctime">
		<label class="control-label col-md-4" for="library-ctime">Created</label>
		<div class="col-md-6"><p class="utc-time" style="padding-top: 7px;vertical-align:baseline; vertical-align: -webkit-baseline-middle; vertical-align:-moz-middle-with-baseline;"><?= $library['createTime'] ?></p>

			<div class="help-block"></div></div>
	</div>		<div class="form-group field-library-mtime">
		<label class="control-label col-md-4" for="library-mtime">Last Modified</label>
		<div class="col-md-6"><p class="utc-time" style="padding-top: 7px;vertical-align:baseline; vertical-align: -webkit-baseline-middle; vertical-align:-moz-middle-with-baseline;"><?= $library['updateTime'] ?></p>

			<div class="help-block"></div></div>
	</div>		<div class="form-group field-library-description">
		<label class="control-label col-md-4" for="library-description">Description</label>
		<div class="col-md-6"><textarea id="library-description" class="form-control" name="Library[description]"><?= $library['description'] ?></textarea>

			<div class="help-block"></div></div>
	</div>
	<div class="form-group">
		<div class="col-md-4"></div>
		<div class="col-md-8">
			<button type="submit" id="saveChangeBtn" class="btn btn-primary" name="action" value="modify">Save Changes</button>
		</div>
	</div>
</form>
</body>
</html>